/*************************************************************************
> File Name: stl.cc
> Author: icebear
> Mail: 3322366195@qq.com
> Created Time: 2024-08-17 12:39:31
> Description: IDA PRO 反编译结构文件
************************************************************************/

#ifndef _STL_H_
#define _STL_H_

#include <list>
#include <set>
#include <vector>
#include <string>
#include <iostream>

std::ostream &cout_vec_str(std::vector<std::string *> &vec_str_ref)
{
    for (auto itr = vec_str_ref.begin(); itr != vec_str_ref.end(); itr++)
    {
        std::cout << **itr << "\t";
    }
    return std::cout;
}

void vec_str_clear(std::vector<std::string *> &vec_str_ref)
{
    for (auto itr = vec_str_ref.begin(); itr != vec_str_ref.end(); itr++)
    {
        delete *itr;
        *itr = nullptr;
    }
    vec_str_ref.clear();
}

int main(int argc, char const *argv[])
{

    std::vector<std::string *> *vec_str_p = new std::vector<std::string *>();
    vec_str_p->push_back(new std::string("Hello"));
    vec_str_p->push_back(new std::string("World"));
    cout_vec_str(*vec_str_p) << std::endl;
    vec_str_clear(*vec_str_p);
    if (vec_str_p->size() == 0)
    {
        delete vec_str_p;
        vec_str_p = nullptr;
        std::cout << "empty vector" << std::endl;
    }

    return 0;
}

#endif
